﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefEquipmentTag" :model="stateEquipmentTag.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipmentId_FormItem" prop="LinkedVM.EquipmentId" :label="$t('message.autotrans._Model_EquipmentTag_Equipment')">
          <el-select v-model="stateEquipmentTag.vmModel.LinkedVM.EquipmentId" clearable>
             <el-option v-for="item in stateEquipmentTag.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_EquipCode_FormItem" prop="LinkedVM.EquipCode" :label="$t('message.autotrans._Model_EquipmentTag_EquipCode')">
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.EquipCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DriverType_FormItem" prop="LinkedVM.DriverType" :label="$t('message.autotrans._Model_EquipmentTag_DriverType')">
          <el-select v-model="stateEquipmentTag.vmModel.LinkedVM.DriverType" clearable>
             <el-option key="OpcUa" value="OpcUa" :label="$t('message.autotrans._Enum_DriverTypeEnum_OpcUa')"></el-option>
             <el-option key="None" value="None" :label="$t('message.autotrans._Enum_DriverTypeEnum_None')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_TagName_FormItem" prop="LinkedVM.TagName" :label="$t('message.autotrans._Model_EquipmentTag_TagName')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_TagName')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.TagName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Address_FormItem" prop="LinkedVM.Address" :label="$t('message.autotrans._Model_EquipmentTag_Address')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_Address')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.Address" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Description_FormItem" prop="LinkedVM.Description" :label="$t('message.autotrans._Model_EquipmentTag_Description')">
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.Description" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_TagType_FormItem" prop="LinkedVM.TagType" :label="$t('message.autotrans._Model_EquipmentTag_TagType')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_TagType')}), trigger: 'blur' }]" >
          <el-select v-model="stateEquipmentTag.vmModel.LinkedVM.TagType" clearable>
             <el-option key="Alarm" value="Alarm" :label="$t('message.autotrans._Enum_TagDefineEnum_Alarm')"></el-option>
             <el-option key="Equipment_State" value="Equipment_State" :label="$t('message.autotrans._Enum_TagDefineEnum_Equipment_State')"></el-option>
             <el-option key="Equipment_Mode" value="Equipment_Mode" :label="$t('message.autotrans._Enum_TagDefineEnum_Equipment_Mode')"></el-option>
             <el-option key="Entry_Sign" value="Entry_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_Entry_Sign')"></el-option>
             <el-option key="Entry_SN" value="Entry_SN" :label="$t('message.autotrans._Enum_TagDefineEnum_Entry_SN')"></el-option>
             <el-option key="Entry_Formual" value="Entry_Formual" :label="$t('message.autotrans._Enum_TagDefineEnum_Entry_Formual')"></el-option>
             <el-option key="Entry_Rfid" value="Entry_Rfid" :label="$t('message.autotrans._Enum_TagDefineEnum_Entry_Rfid')"></el-option>
             <el-option key="Archive_Sign" value="Archive_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_Sign')"></el-option>
             <el-option key="Archive_SN" value="Archive_SN" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_SN')"></el-option>
             <el-option key="Archive_Status" value="Archive_Status" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_Status')"></el-option>
             <el-option key="Archive_Formual" value="Archive_Formual" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_Formual')"></el-option>
             <el-option key="Archive_Operator" value="Archive_Operator" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_Operator')"></el-option>
             <el-option key="Archive_Shift" value="Archive_Shift" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_Shift')"></el-option>
             <el-option key="Archive_Rfid" value="Archive_Rfid" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_Rfid')"></el-option>
             <el-option key="Archive_CycleTime" value="Archive_CycleTime" :label="$t('message.autotrans._Enum_TagDefineEnum_Archive_CycleTime')"></el-option>
             <el-option key="Scan_Sign" value="Scan_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_Scan_Sign')"></el-option>
             <el-option key="Scan_Barcode" value="Scan_Barcode" :label="$t('message.autotrans._Enum_TagDefineEnum_Scan_Barcode')"></el-option>
             <el-option key="Scan_Step" value="Scan_Step" :label="$t('message.autotrans._Enum_TagDefineEnum_Scan_Step')"></el-option>
             <el-option key="ScanBatch_Sign" value="ScanBatch_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_ScanBatch_Sign')"></el-option>
             <el-option key="ScanBatch_Formual" value="ScanBatch_Formual" :label="$t('message.autotrans._Enum_TagDefineEnum_ScanBatch_Formual')"></el-option>
             <el-option key="ScanBatch_01_Sign" value="ScanBatch_01_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_ScanBatch_01_Sign')"></el-option>
             <el-option key="ScanBatch_02_Sign" value="ScanBatch_02_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_ScanBatch_02_Sign')"></el-option>
             <el-option key="ScanBatch_Barcode" value="ScanBatch_Barcode" :label="$t('message.autotrans._Enum_TagDefineEnum_ScanBatch_Barcode')"></el-option>
             <el-option key="TakePartIn_Sign" value="TakePartIn_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_TakePartIn_Sign')"></el-option>
             <el-option key="TakePartIn_SN" value="TakePartIn_SN" :label="$t('message.autotrans._Enum_TagDefineEnum_TakePartIn_SN')"></el-option>
             <el-option key="SpotCheck_Sign" value="SpotCheck_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_SpotCheck_Sign')"></el-option>
             <el-option key="SpotCheck_01_Sign" value="SpotCheck_01_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_SpotCheck_01_Sign')"></el-option>
             <el-option key="SpotCheck_02_Sign" value="SpotCheck_02_Sign" :label="$t('message.autotrans._Enum_TagDefineEnum_SpotCheck_02_Sign')"></el-option>
             <el-option key="SpotCheck_Barcode" value="SpotCheck_Barcode" :label="$t('message.autotrans._Enum_TagDefineEnum_SpotCheck_Barcode')"></el-option>
             <el-option key="PLC_Heartbeat" value="PLC_Heartbeat" :label="$t('message.autotrans._Enum_TagDefineEnum_PLC_Heartbeat')"></el-option>
             <el-option key="Parameter" value="Parameter" :label="$t('message.autotrans._Enum_TagDefineEnum_Parameter')"></el-option>
             <el-option key="Result" value="Result" :label="$t('message.autotrans._Enum_TagDefineEnum_Result')"></el-option>
             <el-option key="RealTimeData" value="RealTimeData" :label="$t('message.autotrans._Enum_TagDefineEnum_RealTimeData')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_DataType_FormItem" prop="LinkedVM.DataType" :label="$t('message.autotrans._Model_EquipmentTag_DataType')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_DataType')}), trigger: 'blur' }]" >
          <el-select v-model="stateEquipmentTag.vmModel.LinkedVM.DataType" clearable>
             <el-option key="Sys_Bit" value="Sys_Bit" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Bit')"></el-option>
             <el-option key="Sys_Byte" value="Sys_Byte" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Byte')"></el-option>
             <el-option key="Sys_Word" value="Sys_Word" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Word')"></el-option>
             <el-option key="Sys_DWork" value="Sys_DWork" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_DWork')"></el-option>
             <el-option key="Sys_Int" value="Sys_Int" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Int')"></el-option>
             <el-option key="Sys_DInt" value="Sys_DInt" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_DInt')"></el-option>
             <el-option key="Sys_Real" value="Sys_Real" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Real')"></el-option>
             <el-option key="Sys_LReal" value="Sys_LReal" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_LReal')"></el-option>
             <el-option key="Sys_String" value="Sys_String" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_String')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ScanRate_FormItem" prop="LinkedVM.ScanRate" :label="$t('message.autotrans._Model_EquipmentTag_ScanRate')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_ScanRate')}), trigger: 'blur' }]" >
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.ScanRate" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_GroupType_FormItem" prop="LinkedVM.GroupType" :label="$t('message.autotrans._Model_EquipmentTag_GroupType')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_GroupType')}), trigger: 'blur' }]" >
          <el-select v-model="stateEquipmentTag.vmModel.LinkedVM.GroupType" clearable>
             <el-option key="Entry" value="Entry" :label="$t('message.autotrans._Enum_TagGroupEnum_Entry')"></el-option>
             <el-option key="Archive" value="Archive" :label="$t('message.autotrans._Enum_TagGroupEnum_Archive')"></el-option>
             <el-option key="Rewrok" value="Rewrok" :label="$t('message.autotrans._Enum_TagGroupEnum_Rewrok')"></el-option>
             <el-option key="NG" value="NG" :label="$t('message.autotrans._Enum_TagGroupEnum_NG')"></el-option>
             <el-option key="None" value="None" :label="$t('message.autotrans._Enum_TagGroupEnum_None')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_AccessMode_FormItem" prop="LinkedVM.AccessMode" :label="$t('message.autotrans._Model_EquipmentTag_AccessMode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_AccessMode')}), trigger: 'blur' }]" >
          <el-select v-model="stateEquipmentTag.vmModel.LinkedVM.AccessMode" clearable>
             <el-option key="Read" value="Read" :label="$t('message.autotrans._Enum_TagAccessModeEnum_Read')"></el-option>
             <el-option key="Write" value="Write" :label="$t('message.autotrans._Enum_TagAccessModeEnum_Write')"></el-option>
             <el-option key="ReadWrite" value="ReadWrite" :label="$t('message.autotrans._Enum_TagAccessModeEnum_ReadWrite')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_UpLimit_FormItem" prop="LinkedVM.UpLimit" :label="$t('message.autotrans._Model_EquipmentTag_UpLimit')">
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.UpLimit" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LowerLimit_FormItem" prop="LinkedVM.LowerLimit" :label="$t('message.autotrans._Model_EquipmentTag_LowerLimit')">
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.LowerLimit" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Active_FormItem" prop="LinkedVM.Active" :label="$t('message.autotrans._Model_EquipmentTag_Active')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_Active')}), trigger: 'blur' }]" >
          <el-switch v-model="stateEquipmentTag.vmModel.LinkedVM.Active" clearable></el-switch>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ActiveLimit_FormItem" prop="LinkedVM.ActiveLimit" :label="$t('message.autotrans._Model_EquipmentTag_ActiveLimit')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentTag_ActiveLimit')}), trigger: 'blur' }]" >
          <el-switch v-model="stateEquipmentTag.vmModel.LinkedVM.ActiveLimit" clearable></el-switch>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Aux_1_FormItem" prop="LinkedVM.Aux_1" :label="$t('message.autotrans._Model_EquipmentTag_Aux_1')">
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.Aux_1" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Aux_2_FormItem" prop="LinkedVM.Aux_2" :label="$t('message.autotrans._Model_EquipmentTag_Aux_2')">
          <el-input v-model="stateEquipmentTag.vmModel.LinkedVM.Aux_2" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitEquipmentTag"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseEquipmentTag"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentTagBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmenttagApi } from '/@/api/equipmentmanagement/equipmenttag';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefEquipmentTag = ref();
const stateEquipmentTag = reactive({
    vmModel: {
	  LinkedVM:{
        EquipmentId: null,
        EquipCode: '',
        DriverType: undefined,
        TagName: '',
        Address: '',
        Description: '',
        TagType: undefined,
        DataType: undefined,
        GroupType: undefined,
        AccessMode: undefined,
        Active: undefined,
        ActiveLimit: undefined,
        Aux_1: '',
        Aux_2: '',
      },
      Ids:[],
      
	},
    
    AllEquipments: [] as any[],
});

// 取消
const onCloseEquipmentTag = () => {
    closeDialog();
};

// 提交
const onSubmitEquipmentTag = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefEquipmentTag.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            equipmenttagApi().batchedit(stateEquipmentTag.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentTag/GetEquipments',[],false).then(x=>{stateEquipmentTag.AllEquipments = x});
    if (ci.attrs["wtmdata"]) {
		stateEquipmentTag.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateEquipmentTag.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

